/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package views;

import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import models.LoginStorage;
import java.lang.String;

/**
 *
 * @author Krzysiek, Aman 
 */
public class TerminalView extends javax.swing.JFrame {

    private LoginStorage model;

    public TerminalView() {
        System.out.println("Login");
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {

                public void run() {
                    setup();
                    setVisible(true);
                }
            });
        } catch (InterruptedException ex) {
            System.out.println(ex.getMessage());
        } catch (InvocationTargetException ex) {
            System.out.println(ex.getMessage());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        runAdminButton = new javax.swing.JButton();
        enter_btn = new javax.swing.JButton();
        useridBox = new javax.swing.JTextField();
        passwordBox = new javax.swing.JPasswordField();
        passwordLabel = new javax.swing.JLabel();
        userIDLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        runAdminButton.setText("Run AdminTool");
        runAdminButton.setPreferredSize(new java.awt.Dimension(100, 20));
        runAdminButton.setBounds(450, 290, 120, 30);
        jLayeredPane1.add(runAdminButton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        enter_btn.setText("Enter/Leave");
        enter_btn.setPreferredSize(new java.awt.Dimension(90, 20));
        enter_btn.setBounds(450, 230, 120, 30);
        jLayeredPane1.add(enter_btn, javax.swing.JLayeredPane.DEFAULT_LAYER);
        useridBox.setBounds(360, 230, 80, 30);
        jLayeredPane1.add(useridBox, javax.swing.JLayeredPane.DEFAULT_LAYER);
        passwordBox.setBounds(360, 290, 80, 30);
        jLayeredPane1.add(passwordBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        passwordLabel.setText("Password");
        passwordLabel.setBounds(360, 270, 60, 14);
        jLayeredPane1.add(passwordLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        userIDLabel.setText("User ID");
        userIDLabel.setBounds(360, 210, 70, 14);
        jLayeredPane1.add(userIDLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Home.jpg"))); // NOI18N
        jLabel1.setBounds(0, 0, 600, 360);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 598, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton enter_btn;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPasswordField passwordBox;
    private javax.swing.JLabel passwordLabel;
    private javax.swing.JButton runAdminButton;
    private javax.swing.JLabel userIDLabel;
    private javax.swing.JTextField useridBox;
    // End of variables declaration//GEN-END:variables
    public void setup() {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AdminView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AdminView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AdminView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AdminView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        initComponents();
    }

    public void addEnterButtonListener(ActionListener enter_btnListener) {
        enter_btn.addActionListener(enter_btnListener);
    }

    public String[] getUserInput() {
        String[] input = new String[2];
        input[0] = useridBox.getText();
        input[1] = new String(passwordBox.getPassword());
        return input;
    }

    public void setModel(LoginStorage model) {
        this.model = model;
    }

    public void addRunAdminButtonListener(ActionListener runAdminListener) {
        runAdminButton.addActionListener(runAdminListener);
    }
}
